<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
	<link href="../css/estilo.css" rel="stylesheet" type="text/css"
		media="screen" />
	<title>TransPort - Cadastro de Logística</title>
</h:head>
<!-- org.apache.bean.util string util -->
<h:body>
	<ui:include src="topo_inc.xhtml" />

	<!-- INICIO CONTEÚDO -->
	<div id="centro">
		<ui:include src="menu_inc.xhtml" />

		<!-- INICIO CADASTRO -->
		<div id="box_cadastro">
			<h:form id="cadastro">
				<p:panel header="Dados para criar conhecimento">
					<p:panelGrid columns="2">
						<p:selectOneMenu filter="true" value="#{cadCRT.motorista}"
							effect="fade" style="width:345px" filterMatchMode="startsWith">
							<f:selectItem itemLabel="Motorista ..." itemValue="" />
							<f:selectItems value="#{cadCRT.motoristas}" var="atual"
								itemLabel="#{atual.nome}" itemValue="#{atual.motoristaID}" />
							<p:ajax update=":cadastro" listener="#{cadCRT.atualizarInicio}" />
						</p:selectOneMenu>

						<p:selectOneMenu filter="true" value="#{cadCRT.veiculo}"
							effect="fade" style="width:345px" filterMatchMode="startsWith">
							<f:selectItem itemLabel="Veiculo ..." itemValue="" />
							<f:selectItems value="#{cadCRT.veiculos}" var="atual"
								itemLabel="#{atual.placa} - Capacidade: #{atual.capacidade}"
								itemValue="#{atual.veiculoID}" />
							<p:ajax update=":cadastro" listener="#{cadCRT.atualizarInicio}" />

						</p:selectOneMenu>
					</p:panelGrid>
				</p:panel>
				<br />
				<p:panel header="Filtros para notas">
					<p:panelGrid columns="4">

						<p:selectOneMenu filter="true" value="#{cadCRT.logistica}"
							disabled="#{cadCRT.habilitarLogistica}" panelStyle="width:150px"
							effect="fade" style="width:160px" filterMatchMode="startsWith">
							<f:selectItem itemLabel="Cliente ..." itemValue="" />
							<f:selectItems value="#{cadCRT.logisticas}" var="atual"
								itemLabel="#{atual.nome}" itemValue="#{atual.logisticaID}" />
							<p:ajax update=":cadastro"
								listener="#{cadCRT.atualizarNotasInicio}" />
						</p:selectOneMenu>

						<p:selectOneMenu filter="true" value="#{cadCRT.estado}"
							disabled="#{cadCRT.habilitarEstado}" panelStyle="width:150px"
							effect="fade" style="width:160px" filterMatchMode="startsWith">
							<f:selectItem itemLabel="Estado ..." itemValue="" />
							<f:selectItems value="#{cadCRT.estados}" var="e" itemLabel="#{e}"
								itemValue="#{e}" />
							<p:ajax update=":cadastro" listener="#{cadCRT.atualizarNotas}" />
						</p:selectOneMenu>

						<p:selectOneMenu filter="true" value="#{cadCRT.cidade}"
							disabled="#{cadCRT.habilitarCidade}" panelStyle="width:150px"
							effect="fade" style="width:160px" filterMatchMode="startsWith">
							<f:selectItem itemLabel="Cidade ..." itemValue="" />
							<f:selectItems value="#{cadCRT.cidades}" var="c" itemLabel="#{c}"
								itemValue="#{c}" />
							<p:ajax update=":cadastro" listener="#{cadCRT.atualizarNotas}" />
						</p:selectOneMenu>

						<p:selectOneMenu filter="true" value="#{cadCRT.cliente}"
							disabled="#{cadCRT.habilitarDestino}" panelStyle="width:150px"
							effect="fade" style="width:160px" filterMatchMode="startsWith">
							<f:selectItem itemLabel="Destino ..." itemValue="" />
							<f:selectItems value="#{cadCRT.clientes}" var="cli"
								itemLabel="#{cli.nome}" itemValue="#{cli.clienteID}" />
							<p:ajax update=":cadastro" listener="#{cadCRT.atualizarNotas}" />
						</p:selectOneMenu>

					</p:panelGrid>
				</p:panel>
				<br />


				<p:growl id="growl" showDetail="true" sticky="false" />
				<p:dataTable id="lista" var="nf" value="#{cadCRT.notasListadas}"
					rowKey="#{nf.nfID}" paginator="true" rows="10"
					selection="#{cadCRT.notasSelecionadas}">

					<f:facet name="header">Selecione as Notas Fiscais</f:facet>

					<p:column selectionMode="multiple" style="width:18px">
						<!-- 
						<p:ajax event="rowSelect"
							listener="#{cadCRT.contadorMais}" render="lista" />
						<p:ajax event="rowUnselect"
							listener="#{cadCRT.contadorMenos}" render="lista" />
							 -->
							 
					</p:column>


					<p:column headerText="Nro. NF">  
            #{nf.nNF}  
        </p:column>

					<p:column headerText="Destino">  
            #{nf.cliente.nome}  
        </p:column>

					<p:column headerText="Peso Bruto">  
            #{nf.pesoBruto}  
        </p:column>

					<p:column headerText="Estado">  
            #{nf.estado}  
        </p:column>

					<p:column headerText="Cidade">  
            #{nf.cidade}  
        </p:column>

					<!--
        <p:ajax  update=":cadastro" event="rowSelectCheckbox" listener="#{cadCRT.amarrarNF}" >
        <f:setPropertyActionListener  value="#{nf}" target="#{cadCRT.nfSelecionada}"/>
        </p:ajax>
        -->

					<f:facet name="footer">


						<p:commandButton id="multiViewButton" value="Finalizar"
							icon="ui-icon-search" update=":cadastro:displayMulti"
							oncomplete="multiDialog.show()" />
					</f:facet>
					<p:messages id="messages" showDetail="true" autoUpdate="true"
						closable="true" />
				</p:dataTable>
				<p:dialog id="multiDialog" header="Revisão do Conhecimento"
					widgetVar="multiDialog" height="300" showEffect="fade"
					hideEffect="fade">

					<p:dataList id="displayMulti" value="#{cadCRT.notasSelecionadas}"
						var="nfSelecao">  
            			Nro NF: #{nfSelecao.nfID} - #{nfSelecao.nNF}, Peso Bruto: #{nfSelecao.pesoBruto}
            		</p:dataList>
					<p:commandButton value="Enviar Conhecimento" id="save"
						actionListener="#{cadCRT.gravar}" update=":cadastro">

					</p:commandButton>

				</p:dialog>
				<h5 class="copyright">Copyright©2012 transport.ftt.com, inc.
					Todos os direitos reservados.</h5>

			</h:form>
		</div>
		<!-- FIM CADASTRO -->
	</div>
	<!-- FIM CONTEÚDO -->
</h:body>

</html>
